import 'package:ac/api/ac_urls.dart';
import 'package:ac/model/ac_login_model.dart';
import 'package:ac/route/ac_route_pages.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'ac_app_preferences.dart';

class AcGlobalController extends GetxController {
  var version = "".obs;
  final rckKey = "".obs;
  final googleKey = "".obs;

  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();
  }

  Future<void> initConfig() async {
    var result = await AcUrls.config.get(
        queryParameters: {"ver": 0},
        showLoading: false,
        showErrorMessage: false);
    if (result?["code"] == 0) {
      var data = result['data'];
      version.value = data['ver'];
      for (var item in data['items']) {
        if (item['name'] == 'rck') {
          rckKey.value = item['data'];
        } else if (item['name'] == 'google_translation_key') {
          googleKey.value = item['data'];
        }
      }
    }
  }

  void initStrategy() async {
    var result = await AcUrls.getStrategy
        .get(showLoading: false, showErrorMessage: false);
  }

}
